package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdSensitive;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.wemedia.service.WmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author tmh
 * @date 2023/8/27 20:07
 * @description 对于敏感词的controller
 */
@Slf4j
@RestController
@RequestMapping("//api/v1/sensitive")
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 查询所有敏感词
     *
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody SensitiveDto sensitiveDto) {
        return wmSensitiveService.findAll(sensitiveDto);
    }

    /**
     * 根据id删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitiveById(@PathVariable("id") Integer id){
        return wmSensitiveService.deleteSensitiveById(id);
    }

    /**
     * 保存敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody AdSensitive adSensitive){
        return wmSensitiveService.saveSensitive(adSensitive);
    }

    /**
     * 修改敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return wmSensitiveService.updateSensitive(adSensitive);
    }
}
